package com.sky.service.impl;

import com.sky.result.Result;
import com.sky.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

@Service
@Slf4j
public class ShopServicelmpl implements ShopService {

    private final static String key = "SHOP_STATUS";
    //将ioc当中的redisbean对象取出来
    @Autowired
    StringRedisTemplate redisTemplate;

    //设置当前店铺状态
    @Override
    public Result setStatus( Integer status) {
        log.info("设置当前店铺状态为{}",status);
        Integer A = status;
        redisTemplate.opsForValue().set(key,A+"");
        return Result.success();
    }

    //查询当前店铺状态
    @Override
    public Result getStatus() {
        log.info("查询店铺状态");
        String status = redisTemplate.opsForValue().get("SHOP_STATUS");
        return Result.success(Integer.parseInt(status));
    }
}
